
<?php
if ($surname_not_match) {
	echo '<div class="error">'. $this->lang->line('searchpnr.surname_does_not_match') .'</div>';
}
echo validation_errors();
echo form_open('services/searchpnr');
?>
<div id="searchPnr">
<table style="font-family: verdana; font-size: 10px; color: #204a5c;">
	<tr>
		<td><?php echo $this->lang->line('pnr');?></td>
		<td><input maxlength="6" id="tags"
			style="border: 1px solid #BBB; color: #444444; background: #FFF;"
			type="text" name="pnr" value="<?php echo set_value('pnr'); ?>"
			size="20"></td>
	</tr>
	<tr>
		<td><?php echo $this->lang->line('surname');?></td>
		<td><input maxlength="20" id="tags2"
			style="border: 1px solid #BBB; color: #444444; background: #FFF;"
			type="text" name="surname"
			value="<?php echo set_value('surname'); ?>" size="20"></td>
	</tr>
	<tr>
		<td colspan="2" align="right"><button value="PNR Görüntüle" type="submit"
			width="100%">PNR Görüntüle</button></td>
	</tr>
</table>

<div>
	<?php 
		if (isset($response_xml)) {
			$exception = $response_xml->xpath('//Exception');
			if (count($exception) > 0) {
				echo '<pre>ERROR OCCURED<BR>-------------';
				echo '<BR>Code       :' . $exception[0]->code;
				echo '<BR>Descriptino:' . $exception[0]->description;
				echo '<BR>Detail     :' . $exception[0]->details;
				echo '</pre>';
			} else { ?> 
				Rezervasyonunuz iptal edilmiştir.
	<?php 	}
		} 
		if (isset($pnr_xml)){
			$exception = $pnr_xml->xpath('//Exception');
			if (count($exception) > 0) {
				echo '<pre>ERROR OCCURED<BR>-------------';
				echo '<BR>Code       :' . $exception[0]->code;
				echo '<BR>Descriptino:' . $exception[0]->description;
				echo '<BR>Detail     :' . $exception[0]->details;
				echo '</pre>';
			} else {
			 $pnr = $pnr_xml->xpath('//pnrView');
			 ?><br><br>


			<div id="passengers" class="showBox">
			<h5><?php echo $this->lang->line('passengers');?></h5><br>
			<table id="itinirary" class="passengers">
				<thead>
					<tr>
						<th align="left" width="70"><?php echo $this->lang->line('title');?></th>
						<th align="left" width="70"><?php echo $this->lang->line('name');?></th>
						<th align="left" width="70"><?php echo $this->lang->line('surname');?></th>
					</tr>
				</thead>
				<tbody>
				<?php
				$passengers=$pnr_xml->xpath('//Passenger');
				foreach($passengers as $passenger) {?>
					<tr>
						<td align="left"><?php echo $passenger->title;?></td>
						<td align="left"><?php echo $passenger->name ;?></td>
						<td align="left"><?php echo $passenger->surname;?></td>
					</tr>
					<?php }?>
				</tbody>
			</table>
			</div><br><br>
			
			
			<div class="showBox" id="itinirary">
			<h5><?php echo $this->lang->line('itinirary');?></h5><br>
			<div style="margin-left: -14px; padding-top:6px;">
			<table class="tb_available" style="width:675px;">
				<thead>
				</thead>
				<tbody>
					<tr>
						<td class="miniTable"><?php echo $this->lang->line('flight');?></td>
						<td class="miniTable"><?php echo $this->lang->line('from');?></td>
						<td class="miniTable"><?php echo $this->lang->line('to');?></td>
						<td class="miniTable"><?php echo $this->lang->line('date');?></td>
						<td class="miniTable"><?php echo $this->lang->line('take_off');?></td>
						<td class="miniTable"><?php echo $this->lang->line('landing');?></td>
						<td class="miniTable"><?php echo $this->lang->line('cabin');?>
						</td>
					</tr>
				<?php
				$segments = $pnr_xml->xpath('//segment');
				foreach($segments as $segment) {?>
					<tr>
						<td class="miniTable2"><?php echo $segment->flightNumber;?></td>
						<td class="miniTable2"><?php echo $segment->from;?></td>
						<td class="miniTable2"><?php echo $segment->to;?></td>
						<td class="miniTable2"><?php echo $segment->date;?></td>
						<td class="miniTable2"><?php echo $segment->departureTime;?></td>
						<td class="miniTable2"><?php echo $segment->arrivalTime;?></td>
						<td class="miniTable2"><?php echo $segment->cabin;?></td>
					</tr>
					<?php }?>
				</tbody>
			</table>
			</div>
			</div>
			</div><br><br>
					<?php if (strpos($pnr[0],'TL-') > -1 ) {?>
			<div>
			<span style="color:#267b21">
				<h2>Rezervasyonumu biletlemek <a href="/bookflight/payfly?pnr=<?php echo $this->commonlibrary->to_en_upper($this->input->post('pnr'));?>&surname=<?php echo $this->commonlibrary->to_en_upper($this->input->post('surname'));?>"> istiyorum.</a></h2>
				</span>
			</div>
			<div>
			<span style="color:#7e0101">
				<h2>Rezervasyonumu iptal etmek <a href="/services/cancelpnr?pnr=<?php echo $this->commonlibrary->to_en_upper($this->input->post('pnr'));?>&surname=<?php echo $this->commonlibrary->to_en_upper($this->input->post('surname'));?>">istiyorum.</a></h2>
				</span><br>
			</div>
					<?php } ?>
			<div id="pnr_view" class="showBox">
			<h5>PNR</h5>
			<pre>
					<?php
					echo $pnr[0];
					?>
			</pre></div>


		<?php }
		} ?></div></div>
